home *** CD-ROM | disk | FTP | other *** search
/ Inventor Labs: Technology / INVENTORLABS_TECHNOLOGY.BIN / pc / files / invest.dir / 00325_Script_Inv Sound Obj < prev    next >
Text File  |  1997-05-26  |  11KB  |  357 lines

  1. --Inv Sound Obj
  2.  
  3. Property pC, pE, pG, pZ, pMixDataIndex, pPuppetSpriteList, pFirstQTmixCastNum
  4. property pCurrentBinaryIndex, pFirstButtonSprite, pFirstWaveBoxSprite
  5. property pFirstWavePicCastNum, pFirstSndCastNum, pFirstWaveSprite
  6. property pMixBoxRect, pRedrawSprite, pQTsprite, pMixedToneList, pMixDisplayState
  7. property pMixCastIndex, pWavePictSpriteNum, pMixable
  8. property pQTFlag
  9. ----------------------------------------------------------ò
  10. on mInit me
  11.   
  12.   set pFirstButtonSprite = 3
  13.   set pFirstWaveBoxSprite = 9
  14.   set pQTsprite = 23
  15.   set pRedrawSprite = 13
  16.   set pFirstWaveSprite = 14
  17.   set pWavePictSpriteNum = 18
  18.   
  19.   set pFirstQTmixCastNum = the number of cast "ce.mov"
  20.   set pFirstWavePicCastNum = the number of cast "ce.pic"
  21.   set pFirstSndCastNum = the number of cast "CE.AIF"
  22.   
  23.   set pPuppetSpriteList = [pQTsprite, pFirstWaveSprite, pFirstWaveSprite+ 1, pFirstWaveSprite +2 , pFirstWaveSprite +3, pRedrawSprite, pWavePictSpriteNum]
  24.   set pMixBoxRect = rect(407, 86, 627, 167)
  25.   
  26.   --put "pMixBoxRect" && pMixBoxRect
  27.   mActivate(me)
  28.   return me
  29.   
  30. end mInit
  31. ----------------------------------------------------------ò
  32. on mActivate me
  33.   
  34.   repeat with x in pPuppetSpriteList
  35.     puppetSprite x, true
  36.   end repeat
  37.   set the text of cast "Mixed Tone List" = ""
  38.   set pMixDisplayState = false
  39.   set pMixCastIndex = 0
  40.   set pCurrentBinaryIndex = 0
  41.   set pMixedToneList = []
  42.   set pC = false
  43.   set pE = false
  44.   set pG = false
  45.   set pZ = false
  46.   set pMixable = false
  47.   --set the visible of sprite pQTsprite = false
  48.   set the locH of sprite pQTsprite = -500--  517 or - 500
  49.   set pMixDataIndex = [:]
  50.   set DataBase = the text of cast "Sound Mixing Database"
  51.   set Limit = the number of lines in DataBase
  52.   repeat with x = 1 to Limit
  53.     set myLine = line x of DataBase
  54.     if char 1 of myLine = "#" then
  55.       set ToneCombo = value(item 1 of myLine)
  56.       set BinaryIndex = value(item 2 of myLine)      
  57.       setaProp(pMixDataIndex, ToneCombo, BinaryIndex)
  58.     end if
  59.   end repeat
  60.   --put "pMixDataIndex = " & pMixDataIndex
  61.   --\
  62.   global gTest
  63.   set gTest = pMixDataIndex
  64.   
  65. end mActivate
  66. ----------------------------------------------------------ò
  67. on mClose me
  68.   
  69.   repeat with x in pPuppetSpriteList
  70.     puppetSprite x, false
  71.   end repeat
  72.   
  73.   --tj&dl
  74.   repeat with n = 2 to 33
  75.     set the puppet of sprite n = 0
  76.     set the visible of sprite n = 1
  77.   end repeat
  78.   puppetsprite 33,  false
  79.   
  80. end mClose
  81. ----------------------------------------------------------ò
  82. on mStartAgain me
  83.   repeat with x = pFirstWaveSprite to (pFirstWaveSprite + 3)
  84.     set the locH of sprite x = -500
  85.     updateStage
  86.   end repeat
  87.   set pC = false
  88.   set pE = false
  89.   set pG = false
  90.   set pZ = false
  91. end mStartAgain
  92. ----------------------------------------------------------ò
  93. on mSetBinaryIndex me
  94.   
  95.   set pCurrentBinaryIndex = 0
  96.   if pC then set pCurrentBinaryIndex = pCurrentBinaryIndex + 1000
  97.   if pE then set pCurrentBinaryIndex = pCurrentBinaryIndex + 100
  98.   if pG then set pCurrentBinaryIndex = pCurrentBinaryIndex + 10
  99.   if pZ then set pCurrentBinaryIndex = pCurrentBinaryIndex + 1
  100.   
  101. end mSetBinaryIndex
  102. ----------------------------------------------------------ò
  103. on mQuickDrawRedraw me
  104.   
  105.   set the rect of sprite pRedrawSprite = pMixBoxRect
  106.   set the visible of sprite pRedrawSprite = false
  107.   set the visible of sprite pRedrawSprite = true
  108.   updateStage
  109.   --set the locH of sprite pRedrawSprite = - 400
  110.   
  111. end mQuickDrawRedraw
  112. ----------------------------------------------------------ò
  113. on mWaveClick me
  114.   
  115.   set NoteStateList = [pC, pE, pG, pZ]
  116.   
  117.   set index = the clickon - pFirstWaveBoxSprite
  118.   set DroppedInTheBox = false
  119.   
  120.   
  121.   --CLEAR OUT PREVIOUSLY MIXED SOUND WAVES
  122.   if pMixDisplayState = #DisplayingPict or pMixDisplayState = #DisplayingQT then
  123.     set the locH of sprite pQTsprite = -500--  517 or - 500
  124.     set the locH of sprite pWavePictSpriteNum = - 400
  125.     set pMixDisplayState = 0
  126.     mQuickDrawRedraw(me)
  127.     set pC = 0
  128.     set pE = 0
  129.     set pG = 0
  130.     set pZ = 0
  131.     set pMixable = 0
  132.   end if
  133.   
  134.   if getAt(NoteStateList, (index + 1)) = 0 then
  135.     repeat while the mouseDown      
  136.       set the locH of sprite (pFirstWaveSprite + index) = the mouseH
  137.       set the locV of sprite (pFirstWaveSprite + index) = the mouseV
  138.       updateStage
  139.     end repeat
  140.     
  141.     if the mouseH > getAt(pMixBoxRect, 1) and the mouseH < getAt(pMixBoxRect, 3) then
  142.       if the mouseV > getAt(pMixBoxRect, 2) and the mouseV < getAt(pMixBoxRect, 4) then
  143.         set DroppedInTheBox = true
  144.         set pMixable = true
  145.       end if
  146.     end if
  147.     
  148.     if DroppedInTheBox then
  149.       set the locH of sprite (pFirstWaveSprite + index) = 517
  150.       set the locV of sprite (pFirstWaveSprite + index) = 127
  151.       updateStage
  152.       if index = 0 then 
  153.         set pC = true
  154.       else if index = 1 then 
  155.         set pE = true
  156.       else if index = 2 then 
  157.         set pG = true
  158.       else if index = 3 then 
  159.         set pZ = true
  160.       end if
  161.     else if not DroppedInTheBox then
  162.       set the locH of sprite  (pFirstWaveSprite + index) = -400
  163.     end if
  164.   end if
  165.   
  166. end mWaveClick
  167. ----------------------------------------------------------ò
  168. on mButtonClick me
  169.   set buttonIndex = the clickOn - pFirstButtonSprite + 1
  170.   put "BUTTON INDEX:" && buttonIndex
  171.   if buttonIndex < 5 then
  172.     mPlayTone(me, buttonIndex)
  173.   else if buttonIndex = 5 then
  174.     mMixTones(me)
  175.   else if buttonIndex = 6 then
  176.     mPlayMixedTone(me)
  177.   end if
  178. end mButtonClick
  179. ----------------------------------------------------------ò
  180. on mPlayTone me, aWhichTone
  181.   set SoundToPlay = the name of cast (pFirstSndCastNum + 10 + aWhichTone)
  182.   puppetSound SoundToPlay
  183. end mPlayTone
  184. ----------------------------------------------------------ò
  185. on mMixTones me
  186.   set Test = pZ + pC + pG + pE
  187.   if Test <= 1 then
  188.   else
  189.     mSetBinaryIndex(me)
  190.     
  191.     set FoundaMatch = false
  192.     set counter = 1
  193.     if pMixable then
  194.       if pCurrentBinaryIndex <> 0 then
  195.         repeat while not FoundaMatch
  196.           set x = getAt(pMixDataIndex, counter)
  197.           if getAt(pMixDataIndex, counter) = pCurrentBinaryIndex then
  198.             set FoundaMatch = true
  199.             set MixLabel = getPropAt(pMixDataIndex, counter)
  200.             set pMixCastIndex = counter
  201.           end if
  202.           set counter = counter + 1
  203.         end repeat
  204.       end if
  205.       
  206.       --tj&dl
  207.       if pQTFlag = #NOQT then
  208.         nothing
  209.       else
  210.         mPlayMixQT(me, MixLabel)
  211.       end if
  212.       
  213.       set pQTFlag = #DEFAULT
  214.     end if
  215.   end if
  216.   
  217. end mMixTones
  218. ----------------------------------------------------------ò
  219. on mPlayMixQT me, aMixLabel
  220.   
  221.   set MixToPlay = pFirstQTmixCastNum + pMixCastIndex - 1
  222.   put "MixToPlay =" && MixToPlay
  223.   put "pFirstQTmixCastNum" && pFirstQTmixCastNum
  224.   put "pMixCastIndex" && pMixCastIndex
  225.   put "The castNumber of the QTFile to play is:" && MixToPlay
  226.   set x = the name of cast MixToPlay
  227.   put "the name of cast MixToPlay" && x
  228.   if the castType of cast MixToPlay = #digitalvideo then
  229.     set the castNum of sprite pQTsprite = value(MixToPlay)
  230.     put "the castNum of sprite pQTsprite: " & the castNum of sprite pQTsprite
  231.     set the movieTime of sprite pQTsprite = 0
  232.     repeat with x = 0 to 3
  233.       set the locH of sprite pFirstWaveSprite + x = - 400
  234.     end repeat
  235.     set the locH of sprite pQTsprite = 517--  517 or - 500
  236.     updateStage
  237.     set the movieRate of sprite pQTsprite = 1
  238.     set pMixDisplayState = #DisplayingQT
  239.     
  240.     if getPos(pMixedToneList, string(aMixLabel)) = 0 then
  241.       add(pMixedToneList, string(aMixLabel))
  242.     end if
  243.     
  244.     --put "pMixedToneList" && pMixedToneList
  245.     set TextBuilder = ""
  246.     repeat with x = 1 to count(pMixedToneList)
  247.       put getAt(pMixedToneList, x) into line x of TextBuilder
  248.     end repeat
  249.     set the text of cast "Mixed Tone List" = TextBuilder
  250.   end if
  251. end mPlayMixQT
  252. ----------------------------------------------------------ò
  253. on mPlayMixedTone me
  254.   
  255.   --tj&dl -- awful hack!
  256.   set NumberOfMixedTones = 0
  257.   if pC = 1 then set NumberOfMixedTones = NumberOfMixedTones + 1
  258.   if pE = 1 then set NumberOfMixedTones = NumberOfMixedTones + 1
  259.   if pG = 1 then set NumberOfMixedTones = NumberOfMixedTones + 1
  260.   if pZ = 1 then set NumberOfMixedTones = NumberOfMixedTones + 1
  261.   
  262.   if NumberOfMixedTones = 1 then
  263.     if pC = 1 then set NewIndex = 1
  264.     else if pE = 1 then set NewIndex = 2
  265.     else if pG = 1 then set NewIndex = 3
  266.     else if pZ = 1 then set NewIndex = 4
  267.     mPlayTone me, NewIndex
  268.   else
  269.     set pQTFlag = #NOQT
  270.     mMixTones(me)
  271.     set SoundToPlay = the name of cast (pFirstSndCastNum + pMixCastIndex - 1)
  272.     puppetSound cast SoundToPlay
  273.   end if
  274.   
  275. end mPlayMixedTone 
  276. ----------------------------------------------------------ò
  277. on mFrameLoop me
  278.   if pMixDisplayState = #DisplayingQT then
  279.     if the movieRate of sprite pQTsprite = 0 then
  280.       mSwapQTforPict(me)
  281.       set pMixDisplayState = #DisplayingPict
  282.     end if
  283.   end if
  284.   go the frame
  285.   
  286. end mFrameLoop
  287. ----------------------------------------------------------ò
  288. on mSwapQTforPict me
  289.   
  290.   --set the visible of sprite pQTsprite = 0
  291.   set the locH of sprite pQTsprite = -500 --    517 or -500
  292.   set NewPictCastNum = pMixCastIndex + pFirstWavePicCastNum - 1
  293.   set the castNum of sprite pWavePictSpriteNum = NewPictCastNum
  294.   set the locH of sprite pWavePictSpriteNum = 517
  295.   set the locV of sprite pWavePictSpriteNum = 127
  296.   mQuickDrawRedraw(me)
  297.   updateStage
  298.   
  299. end mSwapQTforPict
  300. ----------------------------------------------------------ò
  301. on PlayFromMixedToneList me
  302.   set WhichLine = the mouseLIne
  303.   set TheText = word 1 of line WhichLine of field "Mixed Tone List"
  304.   set NumberOfChars = the number of chars of TheText
  305.   put "NumberOfChars:" && NumberOfChars
  306.   
  307.   set pZ = 0
  308.   set pG = 0
  309.   set pE = 0
  310.   set pC = 0
  311.   
  312.   repeat with n = 1 to NumberOfChars
  313.     set nextLetter = char n of TheText
  314.     put nextLetter && charToNum(nextLetter)
  315.     if nextLetter = "C" then
  316.       set pZ = 1
  317.       put "C"
  318.     else if nextLetter = "g" then
  319.       set pG = 1
  320.       put "G"
  321.     else if nextLetter = "e" then
  322.       set pE = 1
  323.       put "E"
  324.     else if nextLetter = "c" then
  325.       set pC = 1
  326.       put "Small C"
  327.     end if
  328.   end repeat
  329.   
  330.   -- put "PlayFrom:" && "C:" && TempC && "E:" && TempE && "G:" && TempG && "c:" && TempZ
  331.   
  332.   --  set TempBinaryIndex = 0
  333.   --  if TempC then set TempBinaryIndex = TempBinaryIndex + 1000
  334.   --  if TempE then set TempBinaryIndex = TempBinaryIndex + 100
  335.   --  if TempG then set TempBinaryIndex = TempBinaryIndex + 10
  336.   --  if TempZ then set TempBinaryIndex = TempBinaryIndex + 1
  337.   --  
  338.   --  set FoundaMatch = false
  339.   --  set counter = 1
  340.   --  if pCurrentBinaryIndex <> 0 then
  341.   --    repeat while not FoundaMatch
  342.   --      set x = getAt(pMixDataIndex, counter)
  343.   --      if getAt(pMixDataIndex, counter) = TempBinaryIndex then
  344.   --        set FoundaMatch = true
  345.   --        set MixLabel = getPropAt(pMixDataIndex, counter)
  346.   --        -- set pMixCastIndex = counter
  347.   --      end if
  348.   --      set counter = counter + 1
  349.   --    end repeat
  350.   
  351.   mPlayMixedTone me
  352.   -- mPlayMixQT(me, MixLabel)
  353.   
  354. end if
  355.  
  356. end
  357. ----------------------------------------------------------ò